package mya.mes.mdc.model.alarm;

import com.alibaba.fastjson.JSONObject;
import mya.mes.mdc.model.tag.convert.AlarmConverter;

public class Alarm {
  /**
   * mongoDb主键
   */
  public String _id;

  /**
   * 报警号：报警日期 + 流水号（6位长度);
   */
  public String alarmNo;

  /**
   * 系统报警
   */
  public Boolean systemAlarm;

  /**
   * 报警日期
   */
  public String alarmDate;

  /**
   * 报警时间
   */
  public String alarmTime;

  /**
   * 报警日流水号
   */
  public Integer alarmSeq;


  /**
   * 关闭日期
   */
  public String closeDate;

  /**
   * 关闭时间
   */
  public String closeTime;


  /**
   * 报警车间
   */
  public String shop;

  /**
   * 报警区域,如BD1/SECTION1
   */
  public String area;

  /**
   * 报警区域：如 SECTION1
   */
  public String section;

  /**
   * 报警点,如TC01 = ViewTag
   */
  public String point;

  /**
   * 对应的MdcTag
   */
  public String mdcTag;

  /**
   * true =表示设备在维修
   */
  public Boolean maint = false;

  /**
   * 对应MdcTag中定义的数组的index
   */
  public Integer mdcTagIndex;
  /**
   * 报警状态, TRUE = 已经关闭， FALSE=未关闭
   */
  public Boolean isClosed = false;

//  /**
//   * 触发时间
//   */
//  public String dtStart;
//
//  /**
//   * 关闭时间
//   */
//  public String dtClose;

  /**
   * 报警持续时间:1小时10分钟20秒
   */
  public String timeSpan;

  /**
   * 报警持续时间：秒
   */
  public Long timeSpanSec;

  /**
   * 报警内容(默认为中文) :zhCN
   */
  public String zhCN;

  /**
   * 报警内容（英文）
   */
  public String enUs;


  /**
   * 发送公众号消息
   */
  public Boolean msgNotice;


  public Long timestamp;


  public Long msgToWeixin;


  /**
   * 已经发送到微信
   */
  public Boolean weixinSent = false;

  public Long msgToManager;

  /**
   * 已经发送到
   */
  public Boolean managerSent = false;

  public Boolean needSendToManager;//是否给管理者发送

  public Boolean needSendToPerson;//是否给普通工人发送

  public Alarm() {
  }

  public Alarm(JSONObject json) {
    AlarmConverter.fromJson(json.entrySet(), this);
    this._id = json.getString("_id");
  }

  public JSONObject toJson() {
    JSONObject json = new JSONObject();
    AlarmConverter.toJson(this, json);
    if (_id != null) {
      json.put("_id", _id);
    }
    return json;
  }


  public String buildKey() {
    return mdcTag + "#" + mdcTagIndex;
  }

  public String get_id() {
    return _id;
  }

  public void set_id(String _id) {
    this._id = _id;
  }

  public String getAlarmNo() {
    return alarmNo;
  }

  public void setAlarmNo(String alarmNo) {
    this.alarmNo = alarmNo;
  }

  public Boolean getSystemAlarm() {
    return systemAlarm;
  }

  public void setSystemAlarm(Boolean systemAlarm) {
    this.systemAlarm = systemAlarm;
  }

  public String getAlarmDate() {
    return alarmDate;
  }

  public void setAlarmDate(String alarmDate) {
    this.alarmDate = alarmDate;
  }

  public String getAlarmTime() {
    return alarmTime;
  }

  public void setAlarmTime(String alarmTime) {
    this.alarmTime = alarmTime;
  }

  public Integer getAlarmSeq() {
    return alarmSeq;
  }

  public void setAlarmSeq(Integer alarmSeq) {
    this.alarmSeq = alarmSeq;
  }

  public String getCloseDate() {
    return closeDate;
  }

  public void setCloseDate(String closeDate) {
    this.closeDate = closeDate;
  }

  public String getCloseTime() {
    return closeTime;
  }

  public void setCloseTime(String closeTime) {
    this.closeTime = closeTime;
  }

  public String getShop() {
    return shop;
  }

  public void setShop(String shop) {
    this.shop = shop;
  }

  public String getArea() {
    return area;
  }

  public void setArea(String area) {
    this.area = area;
  }

  public String getSection() {
    return section;
  }

  public void setSection(String section) {
    this.section = section;
  }

  public String getPoint() {
    return point;
  }

  public void setPoint(String point) {
    this.point = point;
  }

  public String getMdcTag() {
    return mdcTag;
  }

  public void setMdcTag(String mdcTag) {
    this.mdcTag = mdcTag;
  }

  public Integer getMdcTagIndex() {
    return mdcTagIndex;
  }

  public void setMdcTagIndex(Integer mdcTagIndex) {
    this.mdcTagIndex = mdcTagIndex;
  }

  public Boolean getClosed() {
    return isClosed;
  }

  public void setClosed(Boolean closed) {
    isClosed = closed;
  }

  public String getTimeSpan() {
    return timeSpan;
  }

  public void setTimeSpan(String timeSpan) {
    this.timeSpan = timeSpan;
  }

  public Long getTimeSpanSec() {
    return timeSpanSec;
  }

  public void setTimeSpanSec(Long timeSpanSec) {
    this.timeSpanSec = timeSpanSec;
  }

  public String getZhCN() {
    return zhCN;
  }

  public void setZhCN(String zhCN) {
    this.zhCN = zhCN;
  }

  public String getEnUs() {
    return enUs;
  }

  public void setEnUs(String enUs) {
    this.enUs = enUs;
  }

  public Boolean getMsgNotice() {
    return msgNotice;
  }

  public void setMsgNotice(Boolean msgNotice) {
    this.msgNotice = msgNotice;
  }

  public Long getTimestamp() {
    return timestamp;
  }

  public void setTimestamp(Long timestamp) {
    if (this.timestamp == null) {
      this.timestamp = timestamp;
      AlarmTimestamp.set(this, timestamp);
    }
  }

  public Boolean getMaint() {
    return maint;
  }

  public void setMaint(Boolean maint) {
    this.maint = maint;
  }

  public Long getMsgToWeixin() {
    return msgToWeixin;
  }

  public void setMsgToWeixin(Long msgToWeixin) {
    this.msgToWeixin = msgToWeixin;
  }

  public Boolean getWeixinSent() {
    return weixinSent;
  }

  public void setWeixinSent(Boolean weixinSent) {
    this.weixinSent = weixinSent;
  }

  public Long getMsgToManager() {
    return msgToManager;
  }

  public void setMsgToManager(Long msgToManager) {
    this.msgToManager = msgToManager;
  }

  public Boolean getManagerSent() {
    return managerSent;
  }

  public void setManagerSent(Boolean managerSent) {
    this.managerSent = managerSent;
  }

  public Boolean getNeedSendToManager() {
    return needSendToManager;
  }

  public void setNeedSendToManager(Boolean needSendToManager) {
    this.needSendToManager = needSendToManager;
  }

  public Boolean getNeedSendToPerson() {
    return needSendToPerson;
  }

  public void setNeedSendToPerson(Boolean needSendToPerson) {
    this.needSendToPerson = needSendToPerson;
  }
}
